This class is meant as an emulation of SC2DSlider. last mod: 25-nov-07 sciss
Also refer to JSCView for different behaviour affecting all widgets
| different behaviour | |
| knob | slightly bigger (15x15 pixels vs. 12x12) |
| known issues / todo | |
| focus border | (FIXED?) not adjusted when resizing the component |
Note: please use the abstraction layer GUI.slider2D if possible! (see GUI)
A rectangular element that allows you to control two parameters simultaneously by moving a knob horizontally and vertically.
(
var win;
win = JSCWindow( "JSC2DSlider", Rect( 100, 100, 340, 140 ), resizable: false );
n = JSC2DSlider( win, Rect( 20, 20, 80, 80 )).x_( 1 ).y_( 1 );
n.knobColor_( Color( 0.75, 0.125, 0.25, 0.8 ));
n = JSC2DSlider( win, Rect( 120, 20, 80, 80 )).x_( 0.5 ).y_( 0.5 );
n.knobColor_( Color( 0.125, 0.6, 0.25, 0.8 ));
n = JSC2DSlider( win, Rect( 220, 20, 80, 80 )).x_( 0 ).y_( 0 );
n.knobColor_( Color( 0.125, 0.25, 0.75, 0.8 ));
win.front;
)
// assign an action function. note that 'n' holds the right most (blue) slider.
n.action = { arg b; ("x = "++b.x++"; y = "++b.y).postln };
n.enabled_( false );
n.enabled_( true );
n.x_( 0.66 );
n.y_( 0.33 );
// snap values
n.step_( 0.25 );
// no snapping
n.step_( 0.0 );
Drag and drop returns and accepts Points. Hold ctrl key to initiate a drag.
R | random x/y |
N | minimum x/y |
X | maximum x/y |
C | center x/y |
csr left/down | decrease x/y |
csr right/up | increase x/y |